package com.gyyweishang.controller;

import com.gyyweishang.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

@Slf4j
@RestController
public class UploadController {

    @PostMapping("/upload")
    public Result upload(String info, String desc, MultipartFile file) throws IOException {
        log.info("接收到的参数:{}，{}，{}", info, desc, file);
        //保存文件
        String uuid = UUID.randomUUID().toString();
        file.transferTo(new File("D:/images/" + uuid + " " +file.getOriginalFilename()));

        return Result.success();
    }
}
